﻿<UserControl
    x:Class="Results.Views.PlayerView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Icons="clr-namespace:Results.Icons"
    mc:Ignorable="d">
    <Grid
        x:Name="LayoutRoot"
        Background="{x:Null}">
        <Grid.RowDefinitions>
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="*" />
        </Grid.RowDefinitions>
        <StackPanel
            x:Name="PlayerInfo"
            Orientation="Horizontal">
            <Icons:PlayerIcon
                Width="30"
                Height="50"
                Margin="4"
                Gender="{Binding Gender}" />
            <Grid
                Margin="4">
                <Grid.Background>
                    <LinearGradientBrush
                        EndPoint="0.5,1"
                        StartPoint="0.5,0">
                        <GradientStop
                            Color="#80808080"
                            Offset="0" />
                        <GradientStop
                            Color="#80FFFFFF"
                            Offset="1" />
                    </LinearGradientBrush>
                </Grid.Background>
                <StackPanel
                    Orientation="Vertical"
                    Margin="4">
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="{Binding LastName}"
                            FontSize="18" />
                        <TextBlock
                            Text=", "
                            FontSize="18" />
                        <TextBlock
                            Text="{Binding FirstName}"
                            FontSize="18" />
                    </StackPanel>
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="Graduation: " />
                        <TextBlock
                            Text="{Binding GraduationYear}" />
                    </StackPanel>
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="Hometown: " />
                        <TextBlock
                            Text="{Binding Hometown}" />
                    </StackPanel>
                </StackPanel>
            </Grid>
            <ItemsControl
                ItemsSource="{Binding Seasons}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid
                            Margin="4">
                            <Grid.Background>
                                <LinearGradientBrush
                                    EndPoint="0.5,1"
                                    StartPoint="0.5,0">
                                    <GradientStop
                                        Color="#80808080"
                                        Offset="0" />
                                    <GradientStop
                                        Color="#80FFFFFF"
                                        Offset="1" />
                                </LinearGradientBrush>
                            </Grid.Background>
                            <StackPanel
                                Orientation="Vertical"
                                Margin="4">
                                <TextBlock
                                    Text="{Binding Season}"
                                    VerticalAlignment="Center"
                                    FontSize="18" />
                                <TextBlock
                                    Text="{Binding Group}" />
                                <StackPanel
                                    Orientation="Horizontal">
                                    <TextBlock
                                        Text="Average: " />
                                    <TextBlock
                                        Text="{Binding Average}" />
                                </StackPanel>
                                <StackPanel
                                    Orientation="Horizontal">
                                    <TextBlock
                                        Text="Lowest: " />
                                    <TextBlock
                                        Text="{Binding Lowest}" />
                                </StackPanel>
                                <StackPanel
                                    Orientation="Horizontal">
                                    <TextBlock
                                        Text="Points: " />
                                    <TextBlock
                                        Text="{Binding Points}" />
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel
                            Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </StackPanel>
        <Grid
            Grid.Row="2"
            Margin="4">
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition
                    Height="*" />
            </Grid.RowDefinitions>
            <StackPanel
                x:Name="Header"
                Margin="5,0,0,0"
                Orientation="Horizontal"
                HorizontalAlignment="Left">
                <StackPanel.Background>
                    <LinearGradientBrush
                        EndPoint="0.5,1"
                        StartPoint="0.5,0">
                        <GradientStop
                            Color="#FF9DE271"
                            Offset="0" />
                        <GradientStop
                            Color="#FF969696"
                            Offset="1" />
                    </LinearGradientBrush>
                </StackPanel.Background>
                <TextBlock
                    Text="Date"
                    VerticalAlignment="Center"
                    Width="150" />
                <TextBlock
                    Text="Tournament"
                    VerticalAlignment="Center"
                    Width="400" />
                <TextBlock
                    Text="Round1"
                    VerticalAlignment="Center"
                    Width="50" />
                <TextBlock
                    Text="Round2"
                    VerticalAlignment="Center"
                    Width="50" />
                <TextBlock
                    Text="Total"
                    VerticalAlignment="Center"
                    Width="50" />
                <TextBlock
                    Text="Place"
                    VerticalAlignment="Center"
                    Width="50" />
                <TextBlock
                    Text="Points"
                    VerticalAlignment="Center"
                    Width="50" />
                <TextBlock
                    Text="Division"
                    VerticalAlignment="Center"
                    Width="125" />
            </StackPanel>
            <ScrollViewer
                Grid.Row="2"
                HorizontalAlignment="Left">
                <ItemsControl
                    x:Name="Detail"
                    ItemsSource="{Binding Results}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Button
                                Command="{Binding TournamentSelected}">
                                <StackPanel
                                    Orientation="Horizontal"
                                    HorizontalAlignment="Left">
                                    <TextBlock
                                        Text="{Binding FormattedDate}"
                                        VerticalAlignment="Center"
                                        Width="150" />
                                    <TextBlock
                                        Text="{Binding Tournament}"
                                        VerticalAlignment="Center"
                                        Width="400" />
                                    <TextBlock
                                        Text="{Binding Round1}"
                                        VerticalAlignment="Center"
                                        Width="50" />
                                    <TextBlock
                                        Text="{Binding Round2}"
                                        VerticalAlignment="Center"
                                        Width="50" />
                                    <TextBlock
                                        Text="{Binding Total}"
                                        VerticalAlignment="Center"
                                        Width="50" />
                                    <TextBlock
                                        Text="{Binding Place}"
                                        VerticalAlignment="Center"
                                        Width="50" />
                                    <TextBlock
                                        Text="{Binding Points}"
                                        VerticalAlignment="Center"
                                        Width="50" />
                                    <TextBlock
                                        Text="{Binding Group}"
                                        VerticalAlignment="Center"
                                        Width="125" />
                                </StackPanel>
                            </Button>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel
                                Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </ScrollViewer>
        </Grid>
    </Grid>
</UserControl>
